using UnityEngine;
using System.Collections;

public class TurnToTargetRotationOnUpdate : CharacterAction
{
	public float rotationSpeed = 30;
	public bool turnImmediately = false;
	public override void OnFrameUpdate (Character.FrameUpdate arg)
	{
		Character character = arg.character;

		if(turnImmediately){
			character.transform.rotation = Quaternion.Euler(new Vector3(0, character.targetRotation, 0));
			return;
		}
		character.transform.rotation = Quaternion.Lerp(character.transform.rotation, 
		                                               Quaternion.Euler(new Vector3(0, character.targetRotation, 0)),
		                                               rotationSpeed * Time.fixedDeltaTime);
	}
}

